package cn.yuanqiao.archive.report.service.impl;/**
 * @author 赵常飞
 * @date 2023/11/28 15:17
 */

import cn.yuanqiao.archive.appManager.domain.TenantCategory;
import cn.yuanqiao.archive.appManager.domain.TenantSysDictData;
import cn.yuanqiao.archive.appManager.domain.TenantYqda;
import cn.yuanqiao.archive.appManager.domain.TenantYqdaFolder;
import cn.yuanqiao.archive.appManager.mapper.TenantCategoryMapper;
import cn.yuanqiao.archive.appManager.service.ITenantSysDictTypeService;
import cn.yuanqiao.archive.danganzhengli.domain.FileAssociation;
import cn.yuanqiao.archive.management.utils.StringUtils;
import cn.yuanqiao.archive.qzj.domain.YqdaQzjInfo;
import cn.yuanqiao.archive.qzj.mapper.YqdaQzjInfoMapper;
import cn.yuanqiao.archive.report.mapper.getStaicModelDataMapper;
import cn.yuanqiao.archive.report.service.getStaticModelDataService;
import cn.yuanqiao.archive.shuzihua.filter.CustomNullToEmptyStringFilter;
import cn.yuanqiao.archive.storeRoom.domain.Box;
import cn.yuanqiao.archive.storeRoom.domain.CategoryConstants;
import cn.yuanqiao.archive.storeRoom.domain.DaBox;
import cn.yuanqiao.common.enums.DbIdEnum;
import cn.yuanqiao.common.exception.ServiceException;
import cn.yuanqiao.common.utils.SecurityUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.ValueFilter;
import com.alibaba.fastjson2.JSONObject;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *@Author: 赵常飞
 *@Date: 2023/11/28 15:17
 *@Description:
 *@Note:
 */
@Service
public class getStaicModelDataServiceImpl implements getStaticModelDataService {
    @Autowired
    private getStaicModelDataMapper dataMapper;
    @Autowired
    private TenantCategoryMapper categoryMapperMapper;
    @Autowired
    private ITenantSysDictTypeService dictTypeService;
    @Autowired
    private SqlSessionFactory sqlSessionFactory;
    @Autowired
    private YqdaQzjInfoMapper qzjInfoMapper;
    private static String dataBaseId;

    @Override
    public String getbkbdata(JSONObject jsonObject) {
        Long categoryId=jsonObject.getLong("categoryId");
        String catetable=new TenantCategory().getTableName();
        String tenantCode = SecurityUtils.getLoginUser().getUser().getTenantCode();
        String qzname=dataMapper.getbkbdata(categoryId,catetable,tenantCode);
        String returnjson="{\"data\":[{\"QZH\":\""+qzname+"\"}]}";
        return returnjson;
    }
    @Override
    public String getqymldata(com.alibaba.fastjson.JSONObject jsonObject) {
        Long folderId = jsonObject.getLong("folderId");
        Long categoryId=jsonObject.getLong("categoryId");
        String returnjson="{\"data\":[\"data1\",\"data2\"],\"datalist\":[[{\"\":\"\"}],[{\"\":\"\"}]]}";
        TenantCategory category = categoryMapperMapper.selectTenantCategoryByID(categoryId, new TenantCategory().getTableName());

        com.alibaba.fastjson.JSONObject alljson=new com.alibaba.fastjson.JSONObject(1<<1);
        alljson.put("data",new ArrayList<String>(){{
            add("data1");
            add("data2");
        }});
        JSONArray ajmap=new JSONArray(1<<1);
        com.alibaba.fastjson.JSONObject maps = new com.alibaba.fastjson.JSONObject(1);
        TenantYqdaFolder yqdaFolder = new TenantYqdaFolder();
        maps.put("data",(dataMapper.getfolderdata(folderId,category.getFolderTableName(),yqdaFolder.getTableName(),new TenantSysDictData().getTableName())));
        ajmap.add(maps);
        maps = new com.alibaba.fastjson.JSONObject(1);
        maps.put("data",dataMapper.getdadata(folderId,category.getFileTableName(),yqdaFolder.getTableName()));//档案数据
        ajmap.add(maps);
        alljson.put("datalist",ajmap);
        return alljson.toJSONString(alljson, SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String getBoxFmData(com.alibaba.fastjson.JSONObject jsonObject) {
        Map<String,Object> map=new HashMap();
        List<Map<String,Object>> list=new ArrayList<>();
        Long categoryId=jsonObject.getLong("categoryId");
        Long boxId=jsonObject.getLong("boxId");
        TenantCategory category=categoryMapperMapper.selectTenantCategoryByID(categoryId,new TenantCategory().getTableName());
        String code=category.getCode();
        if(code.equals(CategoryConstants.CGHT)||code.equals(CategoryConstants.FWHT)||code.equals(CategoryConstants.XMHT)
                ||code.equals(CategoryConstants.GLXY)||code.equals(CategoryConstants.QTHT)){
            list=dataMapper.getFmDate(boxId,SecurityUtils.getTenantCode(),new Box().getTableName());
            for(int i=0;i<list.size();i++){
                String bgqx="";
                Map<String,Object> boxMap=list.get(i);
                if(!StringUtils.isNULL(boxMap.get("BGQX"))){
                    List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("BGQX");
                    for(TenantSysDictData sysDictData:dictDatas){
                        if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("BGQX")))){
                            bgqx = sysDictData.getDictLabel();
                            break;
                        }
                    }
                }
                boxMap.put("BGQX",bgqx);
                list.set(i,boxMap);
            }
        }else{
            list=dataMapper.getFmQzhDate(boxId,SecurityUtils.getTenantCode(),new Box().getTableName());

        }
        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase; // 可选：设置属性命名策略
        map.put("data",list);
        List newList=new ArrayList();
        newList.add(map);
        return  com.alibaba.fastjson.JSONObject.toJSONString(
                newList,
                serializeConfig,
                new ValueFilter[] { new CustomNullToEmptyStringFilter() }, // 应用自定义过滤器
                //     SerializerFeature.PrettyFormat, // 美化输出
                SerializerFeature.WriteMapNullValue // 不需要这个特性，因为我们自定义了null处理
        );

    }

    @Override
    public String getBoxHjData(com.alibaba.fastjson.JSONObject jsonObject) {
        Map<String,Object> map=new HashMap();
        List<Map<String,Object>> list=new ArrayList<>();
        Long categoryId=jsonObject.getLong("categoryId");
        List boxIds= (List) jsonObject.get("boxIds");
        TenantCategory category=categoryMapperMapper.selectTenantCategoryByID(categoryId,new TenantCategory().getTableName());
        //如果是文书获取分类号
        list=dataMapper.getBoxHjData(boxIds,SecurityUtils.getTenantCode(),new Box().getTableName());
        for(int i=0;i<list.size();i++){
            String bgqx="";
            String flh="";
            Map<String,Object> boxMap=list.get(i);
            if(!StringUtils.isNULL(boxMap.get("BGQX"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("BGQX");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("BGQX")))){
                        bgqx = sysDictData.getDictLabel();
                        break;
                    }
                }
            }
            if(!StringUtils.isNULL(boxMap.get("FLH"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("WSJANFLH");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("FLH")))){
                        flh = sysDictData.getDictLabel();
                        break;
                    }
                }
            }
            boxMap.put("FLH",flh);
            boxMap.put("BGQX",bgqx);

            list.set(i,boxMap);
        }
        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase; // 可选：设置属性命名策略
        map.put("data",list);
        List newList=new ArrayList();
        newList.add(map);
        return  com.alibaba.fastjson.JSONObject.toJSONString(
                newList,
                serializeConfig,
                new ValueFilter[] { new CustomNullToEmptyStringFilter() }, // 应用自定义过滤器
                //   SerializerFeature.PrettyFormat, // 美化输出
                SerializerFeature.WriteMapNullValue // 不需要这个特性，因为我们自定义了null处理
        );
    }

    @Override
    public String getBoxMlData(com.alibaba.fastjson.JSONObject jsonObject) {
        Map<String,Object> map=new HashMap();
        List<Map<String,Object>> list=new ArrayList<>();
        Long categoryId=jsonObject.getLong("categoryId");
        Long boxId=jsonObject.getLong("boxId");
        TenantCategory category=categoryMapperMapper.selectTenantCategoryByID(categoryId,new TenantCategory().getTableName());
        String code=category.getCode();
        if(code.equals(CategoryConstants.WSJIAN)){
            String fields=" ROW_NUMBER() OVER (ORDER BY a.DA_ID) AS \"XH\",b.DH AS \"DH\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\"," +
                    "  b.RQ AS \"RQ\",b.BGQX AS \"BGQX\",b.MJ AS \"MJ\",b.YS AS \"YS\",b.BZ AS \"BZ\"";
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);
        } else if(code.equals(CategoryConstants.SWL)) {
            String fields="";
            if(dataBaseId.equalsIgnoreCase(DbIdEnum.HIGHGO.getCode())) {
                fields = " ROW_NUMBER() OVER (ORDER BY a.DA_ID) AS \"XH\",b.DH AS \"DH\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\",b.SWLY AS \"SWLY\"," +
                        "  b.RQ AS \"RQ\",b.CJH AS \"CJH\",b.BZ AS \"BZ\",(SELECT string_agg(e.DH,',') FROM "+new TenantYqda().getTableName() +" e RIGHT JOIN " +
                        " "+new FileAssociation().getTableName()+" f  ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";
            }else{
                fields = " ROW_NUMBER() OVER (ORDER BY a.DA_ID) AS \"XH\",b.DH AS \"DH\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\",b.SWLY AS \"SWLY\"," +
                        "  b.RQ AS \"RQ\",b.CJH AS \"CJH\",b.BZ AS \"BZ\",(SELECT WM_CONCAT(e.DH,',') FROM "+new TenantYqda().getTableName() +" e RIGHT JOIN " +
                        ""+new FileAssociation().getTableName()+" f ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";

            }
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);

        } else if(code.equals(CategoryConstants.SZCCZT)||code.equals(CategoryConstants.TZZTL)) {
            String fields="";
            if(dataBaseId.equalsIgnoreCase(DbIdEnum.HIGHGO.getCode())) {
                fields=" ROW_NUMBER() OVER (ORDER BY a.DA_ID) AS \"XH\",b.DH AS \"DH\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\"," +
                        "  b.RQ AS \"RQ\",b.BGQX AS \"BGQX\",b.ZTGG AS \"ZTGG\",b.CJH AS \"CJH\",b.BZ AS \"BZ\" ,(SELECT string_agg(e.DH,',') FROM " +
                        " "+new TenantYqda().getTableName() +" e RIGHT JOIN "+new FileAssociation().getTableName()+" f ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";

            }else{
                fields=" ROW_NUMBER() OVER (ORDER BY a.DA_ID) AS \"XH\",b.DH AS \"DH\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\"," +
                        "  b.RQ AS \"RQ\",b.BGQX AS \"BGQX\",b.ZTGG AS \"ZTGG\",b.CJH AS \"CJH\",b.BZ AS \"BZ\" ,(SELECT WM_CONCAT(e.DH,',') FROM" +
                        "  "+new TenantYqda().getTableName() +" e RIGHT JOIN "+new FileAssociation().getTableName()+" f ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";
            }
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);
        }else if(code.equals(CategoryConstants.SP)||code.equals(CategoryConstants.YP)) {
            String fields=" b.DH AS \"DH\",b.TITLE AS \"TITLE\",b.ZRZ AS \"ZRZ\",b.RQ AS \"RQ\",b.SC AS \"SC\",b.WZSM AS \"WZSM\", " +
                    "b.CJH AS \"CJH\" ";
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);
        }else if(code.equals(CategoryConstants.ZP)) {
            String fields="";
            if(dataBaseId.equalsIgnoreCase(DbIdEnum.HIGHGO.getCode())) {
                fields = " b.DH AS \"DH\",b.TITLE AS \"TITLE\",b.ZRZ AS \"ZRZ\",b.RQ AS \"RQ\",b.RW AS \"RW\",b.PSDD AS \"PSDD\",b.WZSM AS \"WZSM\", " +
                        "b.CJH AS \"CJH\",(SELECT string_agg(e.DH,',') FROM "+new TenantYqda().getTableName() +" e RIGHT JOIN "+new FileAssociation().getTableName()+" f" +
                        " ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";
            }else{
                fields = " b.DH AS \"DH\",b.TITLE AS \"TITLE\",b.ZRZ AS \"ZRZ\",b.RQ AS \"RQ\",b.RW AS \"RW\",b.PSDD AS \"PSDD\",b.WZSM AS \"WZSM\", " +
                        "b.CJH AS \"CJH\",(SELECT WM_CONCAT(e.DH,',') FROM "+new TenantYqda().getTableName() +" e RIGHT JOIN "+new FileAssociation().getTableName()+" f" +
                        " ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";
            }
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);
        }else if(code.equals(CategoryConstants.LYL)||code.equals(CategoryConstants.LXL)) {
            String fields="";
            if(dataBaseId.equalsIgnoreCase(DbIdEnum.HIGHGO.getCode())){
                fields=" b.DH AS \"DH\",b.TITLE AS \"TITLE\",b.ZRZ AS \"ZRZ\",b.RQ AS \"RQ\",b.SC AS \"SC\",b.ZYRW AS \"ZYRW\",b.PSDD AS \"PSDD\",b.WZSM AS \"WZSM\", " +
                        "b.CJH AS \"CJH\",b.BGQX AS \"BGQX\",(SELECT string_agg(e.DH,',') FROM "+new TenantYqda().getTableName() +" e RIGHT JOIN "+new FileAssociation().getTableName()+" f" +
                        " ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";
            }else{
                fields=" b.DH AS \"DH\",b.TITLE AS \"TITLE\",b.ZRZ AS \"ZRZ\",b.RQ AS \"RQ\",b.SC AS \"SC\",b.ZYRW AS \"ZYRW\",b.PSDD AS \"PSDD\",b.WZSM AS \"WZSM\", " +
                        "b.CJH AS \"CJH\",b.BGQX AS \"BGQX\",(SELECT WM_CONCAT(e.DH,',') FROM "+new TenantYqda().getTableName() +" e RIGHT JOIN "+new FileAssociation().getTableName()+" f" +
                        " ON e.DA_ID=f.GL_ID  WHERE f.DAID=b.ID )  AS \"HJH\" ";
            }
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);
        }else if(code.equals(CategoryConstants.CGHT)||code.equals(CategoryConstants.FWHT)||code.equals(CategoryConstants.XMHT)
                ||code.equals(CategoryConstants.GLXY) ||code.equals(CategoryConstants.QTHT)||code.equals(CategoryConstants.WYDA)||code.equals(CategoryConstants.HTL)
        ) {
            String bh="";
            if(code.equals(CategoryConstants.WYDA)){
                bh=" b.WJBH AS \"WJBH\"";
            }else{
                bh=" b.HTBH AS \"HTBH\"";
            }

            String fields=" ROW_NUMBER() OVER (ORDER BY a.DA_ID) AS \"XH\",b.DH AS \"DH\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\"," +
                    "  b.RQ AS \"RQ\",b.BGQX AS \"BGQX\",b.YS AS \"YS\",b.BZ AS \"BZ\" ";
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);
        }else{
            String fields=" ROW_NUMBER() OVER (ORDER BY a.DA_ID) AS \"XH\",b.DH AS \"DH\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\"," +
                    "  b.RQ AS \"RQ\",b.YS AS \"YS\",b.BZ AS \"BZ\" ";
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);
        }
        for(int i=0;i<list.size();i++){
            String bgqx="";
            String mj="";
            Map<String,Object> boxMap=list.get(i);
            if(!StringUtils.isNULL(boxMap.get("BGQX"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("BGQX");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("BGQX")))){
                        bgqx = sysDictData.getDictLabel();
                        break;
                    }
                }
            }
            if(!StringUtils.isNULL(boxMap.get("MJ"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("MJ");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("MJ")))){
                        mj = sysDictData.getDictLabel();
                        break;
                    }
                }
            }
            boxMap.put("BGQX",bgqx);
            boxMap.put("MJ",mj);
            list.set(i,boxMap);
        }
        map.put("data",list);
        List newList=new ArrayList();
        newList.add(map);
        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase; // 可选：设置属性命名策略
        return  com.alibaba.fastjson.JSONObject.toJSONString(
                newList,
                serializeConfig,
                new ValueFilter[] { new CustomNullToEmptyStringFilter() }, // 应用自定义过滤器
                SerializerFeature.WriteMapNullValue // 不需要这个特性，因为我们自定义了null处理
        );

    }

    @Override
    public String getBoxMlFmData(com.alibaba.fastjson.JSONObject jsonObject) {
        Map<String,Object> map=new HashMap();
        List<Map<String,Object>> list=new ArrayList<>();
        Long categoryId=jsonObject.getLong("categoryId");
        Long boxId=  jsonObject.getLong("boxId");
        TenantCategory category=categoryMapperMapper.selectTenantCategoryByID(categoryId,new TenantCategory().getTableName());
        //如果是文书获取分类号
        list=dataMapper.getBoxMlFmData(boxId,SecurityUtils.getTenantCode(),new Box().getTableName());
        for(int i=0;i<list.size();i++){
            String bgqx="";
            String flh="";
            Map<String,Object> boxMap=list.get(i);
            if(!StringUtils.isNULL(boxMap.get("BGQX"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("BGQX");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("BGQX")))){
                        bgqx = sysDictData.getDictLabel();
                        break;
                    }
                }
            }
            if(!StringUtils.isNULL(boxMap.get("FLH"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("WSJANFLH");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("FLH")))){
                        flh = sysDictData.getDictLabel();
                        break;
                    }
                }
            }
            boxMap.put("FLH",flh);
            boxMap.put("BGQX",bgqx);

            list.set(i,boxMap);
        }
        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase; // 可选：设置属性命名策略
        map.put("data",list);
        List newList=new ArrayList();
        newList.add(map);
        return  com.alibaba.fastjson.JSONObject.toJSONString(
                newList,
                serializeConfig,
                new ValueFilter[] { new CustomNullToEmptyStringFilter() }, // 应用自定义过滤器
                //   SerializerFeature.PrettyFormat, // 美化输出
                SerializerFeature.WriteMapNullValue // 不需要这个特性，因为我们自定义了null处理
        );
    }

    @Override
    public String getBoxBqSmData(com.alibaba.fastjson.JSONObject jsonObject) {
        Map<String,Object> map=new HashMap();
        List<Map<String,Object>> list=new ArrayList<>();
        Long categoryId=jsonObject.getLong("categoryId");
        Long boxId=  jsonObject.getLong("boxId");
        TenantCategory category=categoryMapperMapper.selectTenantCategoryByID(categoryId,new TenantCategory().getTableName());
        //如果是文书获取分类号
        if(category.getCode().equals(CategoryConstants.SWL)){
            String fields=" b.DH AS \"SWBH\", b.SWFLH AS \"SWFLH\",b.SWLB AS \"SWLB\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\",b.RQ AS \"RQ\",b.BGQX AS \"BGQX\" " ;
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);

        }else  if(category.getCode().equals(CategoryConstants.TZZTL)){
            String fields=" DH AS \"DH\",SZFLH AS \"ZTLX\",b.ZTGG AS \"ZTGG\",b.ZRZ AS \"ZRZ\",b.TITLE AS \"TITLE\",b.RQ AS \"RQ\",b.BGQX AS \"BGQX\" " ;
            list=dataMapper.getBoxMlData(boxId,SecurityUtils.getTenantCode(),new DaBox().getTableName(),category.getFileTableName(),fields);

        }else{
            throw new ServiceException("该门类暂无标签说明！");
        }
        for(int i=0;i<list.size();i++){
            String bgqx="";
            String swflh="";
            String ztlx="";
            Map<String,Object> boxMap=list.get(i);
            if(!StringUtils.isNULL(boxMap.get("BGQX"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("BGQX");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("BGQX")))){
                        bgqx = sysDictData.getDictLabel();
                        break;
                    }
                }
            }

            if(!StringUtils.isNULL(boxMap.get("SWFLH"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("SWFLH");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("SWFLH")))){
                        swflh = sysDictData.getDictLabel();
                        break;
                    }
                }
            }

            if(!StringUtils.isNULL(boxMap.get("ZTLX"))){
                List<TenantSysDictData> dictDatas = dictTypeService.selectDictDataByType("SZFLH");
                for(TenantSysDictData sysDictData:dictDatas){
                    if(sysDictData.getDictValue().equals(String.valueOf(boxMap.get("ZTLX")))){
                        ztlx = sysDictData.getDictLabel();
                        break;
                    }
                }
            }
            boxMap.put("SWFLH",swflh);
            boxMap.put("BGQX",bgqx);
            boxMap.put("ZTLX",ztlx);
            list.set(i,boxMap);
        }
        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase; // 可选：设置属性命名策略
        map.put("data",list);
        List newList=new ArrayList();
        newList.add(map);
        return  com.alibaba.fastjson.JSONObject.toJSONString(
                newList,
                serializeConfig,
                new ValueFilter[] { new CustomNullToEmptyStringFilter() }, // 应用自定义过滤器
                //   SerializerFeature.PrettyFormat, // 美化输出
                SerializerFeature.WriteMapNullValue // 不需要这个特性，因为我们自定义了null处理
        );
    }

    @Override
    public String getQzjData(Long treeId) {
        YqdaQzjInfo yqdaQzjInfo = new YqdaQzjInfo();
        yqdaQzjInfo.setTreeId(treeId);
        List<YqdaQzjInfo> list = qzjInfoMapper.selectList(yqdaQzjInfo);
        JSONArray array = new JSONArray();
        for(YqdaQzjInfo info:list){
            com.alibaba.fastjson.JSONObject o = new com.alibaba.fastjson.JSONObject();
            o.put("title",info.getTitle());
            o.put("zrz",info.getZrz());
            o.put("rq",info.getRq());
            o.put("remark",info.getRemark());
            array.add(o);
        }
        com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
        object.put("data",array);
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(object);

        SerializeConfig serializeConfig = new SerializeConfig();
        serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase; // 可选：设置属性命名策略
        return com.alibaba.fastjson.JSONObject.toJSONString(
                jsonArray,
                serializeConfig,
                new ValueFilter[] { new CustomNullToEmptyStringFilter() }, // 应用自定义过滤器
                //   SerializerFeature.PrettyFormat, // 美化输出
                SerializerFeature.WriteMapNullValue // 不需要这个特性，因为我们自定义了null处理
        );
    }

}
